#include<bits/stdc++.h>
using namespace std;
    int T;
    int n,m;
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    scanf("%d%d",&n,&m);
    int x;
    for(int i=1;i<=n+m;i++)cin>>x;
    int k=1;
    while((1<<k)<n)k++;
    k++;
    string ch;
    for(int i=1;i<=k;i++){
        getline(cin,ch);
    }
    cin>>T;
    while(T--){
        printf("1\n");
    }
    return 0;
}